<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>学生体质健康</title>
    <link rel="stylesheet" href="/css/layui.css">
</head>
<body>
<!-- 表格 -->
<table class="layui-hide" id="teacherStuPhy" lay-filter="teacherStuPhyFilter"></table>

<!-- 头部工具栏 -->
<script type="text/html" id="TeacherStuPhyToolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon layui-icon-add-circle"></i>添加学生体质健康</button>
        <button class="layui-btn layui-btn-sm layui-btn-danger" lay-event="deleteAll" ><i class="layui-icon layui-icon-delete"></i>批量删除</button>
        <!--<button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>-->
    </div>
</script>


<!-- 行工具栏 -->
<script type="text/html" id="TeacherPhyByIdBar">
    <a class="layui-btn layui-btn-xs" lay-event="update"><i class="layui-icon layui-icon-edit"></i>编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete"><i class="layui-icon layui-icon-delete"></i>删除</a>
</script>

<!-- 弹出修改界面 -->
<form class="layui-form" id="TeacherStuPhyById" style="display: none" lay-filter="TeacherStuPhyById">
    <div class="layui-form-item">
        <label class="layui-form-label">学号</label>
        <div class="layui-input-inline">
            <input type="text" name="id" lay-verify="required" lay-reqText="请输入正确的学号" placeholder="请输入学号" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="studentName" lay-verify="title" autocomplete="off" placeholder="请输入姓名" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="password" name="password" placeholder="请输入密码" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">班级</label>
        <div class="layui-input-inline">
            <input type="text" name="classesId" lay-verify="required" lay-reqText="请输入正确的班级" placeholder="请输入班级" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-block">
            <input type="radio" name="gender" value="1" title="男" checked="">
            <input type="radio" name="gender" value="2" title="女">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">出生地</label>
        <div class="layui-input-inline">
            <input type="text" name="bornplace" lay-verify="required" lay-reqText="请输入正确的出生地" placeholder="请输入出生地" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">籍贯</label>
        <div class="layui-input-inline">
            <input type="text" name="nativePlace" lay-verify="required" lay-reqText="请输入正确的籍贯" placeholder="请输入籍贯" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">民族</label>
        <div class="layui-input-inline">
            <input type="text" name="nation" lay-verify="required" lay-reqText="请输入正确的民族" placeholder="请输入民族" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">国家</label>
        <div class="layui-input-inline">
            <input type="text" name="country" lay-verify="required" lay-reqText="请输入正确的国家" placeholder="请输入国籍" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">政治面貌</label>
        <div class="layui-input-inline">
            <input type="text" name="political" lay-verify="required" lay-reqText="请输入正确的政治面貌" placeholder="请输入政治面貌" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">证件类型</label>
        <div class="layui-input-inline">
            <select name="certificateId">
                <option value="">请选择证件类型</option>
                <option value="1">二代身份证</option>
                <option value="2">出生证</option>
                <option value="3">护照</option>
                <option value="4">士官证</option>
                <option value="5">港澳通行证</option>
            </select>
        </div>
        <label class="layui-form-label">证件号码</label>
        <div class="layui-input-inline">
            <input type="text" name="certificateNum" lay-verify="required" lay-reqText="请输入正确的证件号码" placeholder="请输入证件号码" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">证件有效期</label>
        <div class="layui-input-inline">
            <input type="date" name="certificateTime" lay-verify="required" lay-reqText="请输入正确的有效期" placeholder="请选择证件有效期" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">年龄</label>
        <div class="layui-input-inline">
            <input type="texts" name="age" lay-verify="required" lay-reqText="请输入正确的年龄" placeholder="请输入年龄" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">居住地址</label>
        <div class="layui-input-inline">
            <input type="text" name="address" lay-verify="required" lay-reqText="请输入正确居住地址" placeholder="请输入居住地址" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">血型</label>
        <div class="layui-input-inline">
            <input type="text" name="bloodtype" lay-verify="required" lay-reqText="请输入正确的血型" placeholder="请输入血型" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">父亲姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="fatherName" lay-verify="required" lay-reqText="请输入正确的父亲姓名" placeholder="请输入父亲姓名" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">母亲姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="motherName" lay-verify="required" lay-reqText="请输入正确的母亲姓名" placeholder="请输入母亲姓名" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">联系电话</label>
        <div class="layui-input-inline">
            <input type="text" name="phone" lay-verify="required | phone" lay-reqText="请输入正确的联系电话" placeholder="请输入联系电话" autocomplete="off" class="layui-input">
        </div>
        <label class="layui-form-label">紧急电话</label>
        <div class="layui-input-inline">
            <input type="text" name="emergentPhone" lay-verify="required | phone" lay-reqText="请输入正确的紧急电话" placeholder="请输入紧急电话" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">宿舍</label>
        <div class="layui-input-inline">
            <select name="dormitoryId">
                <option value="">请选择宿舍</option>
                <option value="1">101</option>
                <option value="2">201</option>
                <option value="3">301</option>
            </select>
        </div>
        <label class="layui-form-label">班主任</label>
        <div class="layui-input-inline">
            <select name="teacherId">
                <option value="">请选择班主任</option>
                <option value="1">文章</option>
                <option value="3">数学王者</option>
                <option value="4">物理大神</option>
                <option value="5">化学牛人</option>
                <option value="7">生物教授</option>
                <option value="9">历史时钟</option>
                <option value="10">政治角斗士</option>
                <option value="13">地理游客</option>
                <option value="15">体育达人</option>
                <option value="16">英语健将</option>
                <option value="17">杂家</option>
                <option value="19">全才</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">身份</label>
        <div class="layui-input-inline">
            <select name="roleId">
                <option value="">请选择身份</option>
                <option value="1">学生</option>
                <option value="2">班长</option>
            </select>
        </div>
        <label class="layui-form-label">理想大学</label>
        <div class="layui-input-inline">
            <input type="text" name="dreamSchool" lay-verify="required | phone" lay-reqText="请输入正确的理想大学" placeholder="请输入理想大学" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">独生子女</label>
        <div class="layui-input-inline">
            <input type="radio" name="isOnly" value="1" title="是">
            <input type="radio" name="isOnly" value="2" title="否" checked="">
        </div>
        <label class="layui-form-label">受过学前教育</label>
        <div class="layui-input-inline">
            <input type="radio" name="isPre" value="1" title="是">
            <input type="radio" name="isPre" value="2" title="否" checked="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">留守儿童</label>
        <div class="layui-input-inline">
            <input type="radio" name="isLeftOver" value="1" title="是">
            <input type="radio" name="isLeftOver" value="2" title="否" checked="">
        </div>
        <label class="layui-form-label">随迁子女</label>
        <div class="layui-input-inline">
            <input type="radio" name="isMigrant" value="1" title="是">
            <input type="radio" name="isMigrant" value="2" title="否" checked="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">进城务工随迁</label>
        <div class="layui-input-inline">
            <input type="radio" name="isMigrantWorker" value="1" title="是">
            <input type="radio" name="isMigrantWorker" value="2" title="否" checked="">
        </div>
        <label class="layui-form-label">孤儿</label>
        <div class="layui-input-inline">
            <input type="radio" name="isOrphan" value="1" title="是">
            <input type="radio" name="isOrphan" value="2" title="否" checked="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">单亲</label>
        <div class="layui-input-inline">
            <input type="radio" name="isSingleParent" value="1" title="是">
            <input type="radio" name="isSingleParent" value="2" title="否" checked="">
        </div>
        <label class="layui-form-label">烈士或优抚子女</label>
        <div class="layui-input-inline">
            <input type="radio" name="isMartyr" value="1" title="是">
            <input type="radio" name="isMartyr" value="2" title="否" checked="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">残疾人</label>
        <div class="layui-input-inline">
            <input type="radio" name="isDisabled" value="1" title="是">
            <input type="radio" name="isDisabled" value="2" title="否" checked="">
        </div>
        <label class="layui-form-label">政府购买学位</label>
        <div class="layui-input-inline">
            <input type="radio" name="isAssinDegree" value="1" title="是">
            <input type="radio" name="isAssinDegree" value="2" title="否" checked="">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">申请资助</label>
        <div class="layui-input-inline">
            <input type="radio" name="isSupport" value="1" title="是">
            <input type="radio" name="isSupport" value="2" title="否" checked="">
        </div>
        <label class="layui-form-label">享受一补</label>
        <div class="layui-input-inline">
            <input type="radio" name="isSubsidy" value="1" title="是">
            <input type="radio" name="isSubsidy" value="2" title="否" checked="">
        </div>
    </div>

    <!--<div class="layui-form-item" style="text-align: center">-->
    <!--<button  class="layui-btn" lay-submit lay-filter="doUpdate">修改</button>-->
    <!--<button  class="layui-btn">重置</button>-->
    <!--</div>-->
</form>

</body>
<script src="/layui.js" charset="utf-8"></script>
<script>
    layui.use(['table','layer','form'],function(){
        let table = layui.table;
        let layer=layui.layer;
        let form=layui.form;

        table.render({
            elem: '#teacherStuPhy'
            ,url:'/teacher/queryAllPhy'
            ,toolbar: "#TeacherStuPhyToolbar"
            ,title: '学生体质健康表'
            ,totalRow: true
            ,cols: [  [
                {field:'id', title:'编号 ', width:80, fixed: 'left', unresize: true, sort: true,align:'center'}
                ,{field:'classesId',width:120, title: '班级',align:'center',templet:function (res) {
                        return res.classes.classesName;
                    }}
                ,{field:'studentInfo',width:120, title: '学生姓名',align:'center', sort: true, templet:function (res) {
                        return res.studentInfo.studentName;
                    }}
                ,{field:'writeTime',width:150, title: '测试时间',align:'center'}
                ,{field:'schoolName', width:120,title: '学校名字',align:'center'}
                ,{field:'height', width:120,title: '身高(cm)', sort: true,align:'center'}
                ,{field:'weight', width:120,title: '体重(kg)', sort: true,align:'center'}
                ,{field:'bmiscore', width:120,title: 'BMI得分', sort: true,align:'center'}
                ,{field:'bmimark', width:120,title: 'BMI评分', sort: true,align:'center'}
                ,{field:'bmilevel', width:120,title: 'BMI等级', sort: true,align:'center'}
                ,{field:'suggest', width:300,title: '建议', sort: true,align:'center'}
                ,{title:"操作",toolbar:"#TeacherPhyByIdBar" ,width:150,fixed:'right',align:'center'}
            ]  ]
            ,page: true
            ,response: {
                statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
            }
            ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.count, //解析数据长度
                    "data": res.data.items //解析数据列表
                };
            }
        });

        //监听头部工具栏事件
        table.on("toolbar(teacherStuPhyFilter)",function (obj) {
            switch (obj.event) {
                case 'add':
                    openAddStuPhy();
                    break;
                case 'deleteAll':
                    openUpdateStu();
                    break;
            }
        });

        //监听行工具栏事件
        table.on('tool(teacherStuPhyFilter)',function (obj) {

            switch (obj.event) {
                case 'update':
                    openUpdateStuPhy(obj.data);
                    break;
                case 'delete':
                    obj.del();
                    TeacherDeleteStuPhy(obj.data);
                    break;
            }
        });

        function openAddStuPhy() {
            layer.open({
                type:2,//弹出层类型
                title:"添加体质健康记录",
                area:['800px','600px'],
                content:'http://localhost:8080/teachers/TeacherAddPhy.html',
                success:function () {
                    $("#addStu")[0].reset()
                }
            })
        }

        let url;//提交地址
        let mainIndex;//窗口索引
        function openUpdateStuPhy(data) {
            mainIndex= layer.open({
                type:1,//弹出层类型
                title:"修改学生体质健康",
                area:['800px','600px'],
                shade: 0,
                btn: ['提交', '重置'],
                btn1: function(index, layero){
                    let data = form.val("TeacherStuPhyById");
                    $.post("/teacher/modifyStuPhy",data,function (res) {
                        if (res.success=="true"){
                            layer.alert("修改成功！",{icon:6,time:2000})
                        }
                    });
                    layer.closeAll();
                    return true;
                },btn2: function(index, layero){
                    $("#TeacherStuPhyById")[0].reset();
                    return false;
                },
                cancel: function(layero,index){
                    layer.closeAll();
                },
                content:$("#TeacherStuPhyById"),
                success:function () {
                    //表单数据回显
                    form.val("TeacherStuPhyById",data);
                }
            })

        }
        function TeacherDeleteStuPhy(data) {
            layer.confirm("确定删除吗？",{icon:3,title:"提示"},function (deleteStu) {
                $.post("/teacher/deleteStuPhy",{id:data.id},function (res) { // "id="+data.id
                    if (res.success=="true"){
                        layer.alert("删除成功！",{icon:6,time: 2000});
                        // layer.close(deleteStu);
                    } else{
                        layer.alert(res.msg,{icon:5,time: 2000})
                    }
                    layer.close(deleteStu);
                })
            })

        }
    });
</script>
</html>